package com.tianji.learning.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tianji.learning.domin.po.PointsBoardSeason;
import com.tianji.learning.mapper.PointsBoardSeasonMapper;
import com.tianji.learning.service.IPointsBoardSeasonService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author author
 * @since 2023-11-09
 */
@Service
@RequiredArgsConstructor
public class PointsBoardSeasonServiceImpl extends ServiceImpl<PointsBoardSeasonMapper, PointsBoardSeason> implements IPointsBoardSeasonService {
    @Override
    public Integer getBoardSeasonByDate(LocalDate date) {

        //查询数据库 根据时间 查不到返回null
        return lambdaQuery().le(PointsBoardSeason::getBeginTime, date).ge(PointsBoardSeason::getEndTime, date).oneOpt().map(PointsBoardSeason::getId).orElse(null);
    }

}
